package com.bsj.power.common.def.vo.web.job;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bsj.power.common.def.entity.job.Job;
import com.bsj.power.common.def.entity.job.QualityPlan;
import com.bsj.power.common.def.entity.path.PathPoint;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description JobCacheVO
 * @time 2024/7/18 11:59
 */
@Data
@NoArgsConstructor
public class JobCacheVO {

    /**
     * Id主键
     */
    private Long jobId;

    /**
     * 工单号
     */
    private String jobNum;

    /**
     * 作业区域（场景名称）
     */
    private String workArea;

    /**
     * 作业计划开始时间
     */
    private Date startTime;

    /**
     * 作业计划结束时间
     */
    private Date endTime;

    /**
     * 作业目标开始时间
     */
    private Date targetTime;

    /**
     * 负责人ID
     */
    private String directorId;

    /**
     * 负责人集团工号
     */
    private String empNo;

    /**
     * 承包商QC选点状态
     */
    private Integer contractorQc;

    /**
     * 维修QC选点状态
     */
    private Integer maintainQc;

    /**
     * 技术支持QC选点状态
     */
    private Integer technicalSupportQc;

    /**
     * 质量计划
     */
    private List<QualityPlan> qualityPlans;

    /**
     * 风险等级 1:低风险，2 中风险 3高风险
     */
    private Integer riskLevel;

    public JobCacheVO(Job job) {
        this.jobId = job.getJobId();
        this.jobNum = job.getJobNum();
        this.workArea = job.getWorkArea();
        this.startTime = job.getStartTime();
        this.endTime = job.getEndTime();
        this.targetTime = job.getTargetTime();
        this.directorId = job.getDirectorId();
        this.contractorQc = job.getContractorQc();
        this.maintainQc = job.getMaintainQc();
        this.technicalSupportQc = job.getTechnicalSupportQc();
        this.riskLevel = job.getRiskLevel();
    }

    public static void main(String[] args) {
        String str = "{\"start\":[213.7500369658982,0.1,-45.97581850198924],\"end\":[193.60405492423803,0.1,-41.65882281203253]}";
        JSONObject jsonObject = JSONObject.parseObject(str);
        JSONArray startArray = jsonObject.getJSONArray("start");
        JSONArray endArray = jsonObject.getJSONArray("end");
        List<PathPoint> pathPoints = new ArrayList<>();
        //开始点
        Double starX = startArray.getDouble(0);
        Double z = startArray.getDouble(1);
        Double starY = startArray.getDouble(2);
        pathPoints.add(new PathPoint(1, starX, starY, z));
        //结束点
        Double endX = endArray.getDouble(0);
        Double endY = endArray.getDouble(2);
        pathPoints.add(new PathPoint(4, endX, endY, z));
        //第二点
        pathPoints.add(new PathPoint(2, endX, starY, z));
        //第三点
        pathPoints.add(new PathPoint(3, starX, endY, z));
        pathPoints.forEach(System.out::println);
    }

}
